package com.yunbiao.ybbusstopplate.refactoring.ui.fengxian;

import android.view.View;

import androidx.databinding.DataBindingUtil;

import com.yunbiao.ybbusstopplate.R;
import com.yunbiao.ybbusstopplate.base.BaseSettingFragment;
import com.yunbiao.ybbusstopplate.refactoring.utils.L;

public class RefactoringLogFragment extends BaseSettingFragment {

    private com.yunbiao.ybbusstopplate.databinding.FragmentRefactoringLogBinding binding;

    @Override
    public int getViewId() {
        return R.layout.fragment_refactoring_log;
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.bind(requireView());

        L.setLogConsumer(s -> {
            binding.tvMessage.post(() -> {
                binding.tvMessage.setText(String.format("%s\n%s", binding.tvMessage.getText(), s));
                binding.svMessage.fullScroll(View.FOCUS_DOWN);
            });
        });

        binding.btnClear.setOnClickListener(v -> {
            binding.tvMessage.setText("");
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        L.setLogConsumer(null);
    }
}
